/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package zilvic.game.character.profile;

import zilvic.game.character.inventory.Inventory;
import zilvic.resources.ByteMagic;


/**
 *
 * @author Erik
 */
public class Profile {
    public static final int DEFAULT_SLOT_COUNT = 8;
    private Inventory inventory = new Inventory(DEFAULT_SLOT_COUNT);
    private int damage;
    private int maxHealth;
    private int maxMana;
    private int strength;
    private int dexterity;
    private int intelligence;
    private int health;
    private int mana;
    
    private void maxHealth(){
        maxHealth = strength * 4 /*+ SkillTree health boosts */;
    }
    //sets your max health

    private void maxMana(){
        maxMana = intelligence * 4 /*+ SkillTree mana boosts */;
    }
    //sets your max mana

    public void healed(int healAmount){
        if (healAmount + health > maxHealth){
            health = maxHealth;
        }else{
            health = health + healAmount;
        }
    }
    //increses your health when you are healed by anything

    public void manaReg(int regAmount){
        if (regAmount*(intelligence / 10) + mana > maxMana){
            mana = maxMana;
        }else{
            mana = mana + regAmount*(intelligence / 10);
        }
    }
    //increses your mana when something gives you mana

    public void takeDamage(int foeDamage){
        if (foeDamage > inventory.getTotalItemArmor()){
        health = health -(foeDamage - inventory.getTotalItemArmor());
        }
    }
    //calculates the damage the foes deals to you when it attacks and reduces your health by that amount

    public int dealDamage(){
        damage = inventory.getTotalWeaponDamage() + strength + dexterity / 2;
        return damage;
    }
    //calculates the damage you deal to enemys when you attack

    public boolean burdened(){
        if (inventory.getTotalWeight() > strength * 2){
            return true;
        }else{
            return false;
        }
    }
    //Calculates if you are burdened or not

    public byte[] healthToBytes(){
        return ByteMagic.compressBytes(new byte[][] {
        ByteMagic.intToBytes(health)});
    }
    //Saves your health in bytes

    public byte[] manaToBytes(){
        return ByteMagic.compressBytes(new byte[][] {
        ByteMagic.intToBytes(mana)});
    }
    //Saves your mana in bytes
}